<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">
<ui:composition template="/resources/template/template.xhtml">

	<ui:define name="title">
		<h:outputText value="Administration des profils" />
	</ui:define>

	<ui:define name="content">

		<h:form>
			<p:panel styleClass="panel-bouton">
				<p:commandButton icon="ui-icon-circle-plus" action="#{administrationProfilBean.initNouveauProfil()}" update="@widgetVar(_dialogModificationProfil)" />
			</p:panel>
			<p:dataTable widgetVar="_datatableProfil" value="#{administrationProfilBean.listeProfil}" var="profil" rowKey="#{profil.id}" selectionMode="single" selection="#{administrationProfilBean.profil}" scrollable="true" scrollHeight="500" emptyMessage="Aucun profil">
				<p:ajax event="rowSelect" listener="#{administrationProfilBean.selectionProfil}" update="@widgetVar(_dialogModificationProfil)" />
				<p:column>
					<f:facet name="header">
						<h:outputText value="LIBELLE" />
					</f:facet>
					<h:outputText value="#{profil.libelle}" />
				</p:column>
				<p:column styleClass="align-center">
					<f:facet name="header">
						<h:outputText value="CONTROLE TOTAL" />
					</f:facet>
					<h:outputText value="#{profil.controleTotal ? 'Oui' : 'Non'}" />
				</p:column>
			</p:dataTable>
		</h:form>

	</ui:define>

	<ui:define name="dialog">

		<h:form>
			<p:dialog widgetVar="_dialogModificationProfil" modal="true" dynamic="true" resizable="false" closeOnEscape="true" showEffect="fade" onHide="PF('_dialogModificationProfil').initPosition()">
				<f:facet name="header">
					<h:outputText value="Profil en #{administrationProfilBean.typeModification}" />
				</f:facet>
				<p:panel header="Informations sur le profil">
					<h:panelGrid columns="2">
						<p:outputLabel value="Libelle" for="idInputLibelle" />
						<p:inputText id="idInputLibelle" value="#{administrationProfilBean.profil.libelle}" size="50" />
						<p:outputLabel value="Contrôle total" for="idSelectBooleanControleTotal" />
						<p:selectBooleanButton id="idSelectBooleanControleTotal" value="#{administrationProfilBean.profil.controleTotal}" offLabel="Non" onLabel="Oui" />
					</h:panelGrid>
				</p:panel>
				<p:panel header="Liste des rôles">
					<p:pickList id="idPicklistRole" value="#{administrationProfilBean.listeRole}" var="role" itemValue="#{role}" itemLabel="#{role.libelle}" showCheckbox="true" showSourceFilter="true" showTargetFilter="true" filterMatchMode="contains" addLabel="Ajouter" addAllLabel="Ajouter tout" removeLabel="Supprimer" removeAllLabel="Supprimer tout"  converter="#{genericConverter}">
						<f:facet name="sourceCaption">
							<h:outputText value="Disponible" />
						</f:facet>
						<f:facet name="targetCaption">
							<h:outputText value="Selectionné" />
						</f:facet>
					</p:pickList>
				</p:panel>
				<f:facet name="footer">
					<p:outputPanel autoUpdate="true" styleClass="align-right">
						<p:commandButton value="Annuler" icon="ui-icon-close" oncomplete="PF('_dialogModificationProfil').hide()" immediate="true" />
						<p:commandButton value="Valider" icon="ui-icon-disk" action="#{administrationProfilBean.valider()}" update="@widgetVar(_datatableProfil)" />
					</p:outputPanel>
				</f:facet>
			</p:dialog>
		</h:form>

	</ui:define>

</ui:composition>
</html>